VERSION 5.00
Begin VB.Form FrmSpaceImpact 
   AutoRedraw      =   -1  'True
   BackColor       =   &H00000000&
   BorderStyle     =   1  'Fixed Single
   Caption         =   "BLacK Impact"
   ClientHeight    =   8145
   ClientLeft      =   150
   ClientTop       =   510
   ClientWidth     =   6885
   FillStyle       =   0  'Solid
   BeginProperty Font 
      Name            =   "MS Sans Serif"
      Size            =   12
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   ForeColor       =   &H000000FF&
   Icon            =   "FrmSpaceImpact.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   MousePointer    =   99  'Custom
   ScaleHeight     =   8145
   ScaleWidth      =   6885
   StartUpPosition =   2  'CenterScreen
   Begin VB.Timer Timer1 
      Interval        =   1
      Left            =   4080
      Top             =   0
   End
   Begin VB.Image imgBackGround 
      Height          =   1800
      Left            =   0
      Top             =   120
      Visible         =   0   'False
      Width           =   1800
   End
   Begin VB.Image imgBadGuyMask 
      Height          =   720
      Left            =   480
      Top             =   5280
      Visible         =   0   'False
      Width           =   825
   End
   Begin VB.Image imgRapFireMask 
      Height          =   885
      Left            =   120
      Top             =   2760
      Visible         =   0   'False
      Width           =   780
   End
   Begin VB.Image imgRapFire 
      Height          =   885
      Left            =   960
      Top             =   3480
      Visible         =   0   'False
      Width           =   780
   End
   Begin VB.Image imgBadGuy 
      Height          =   720
      Left            =   840
      Top             =   6120
      Visible         =   0   'False
      Width           =   825
   End
   Begin VB.Image imgRap 
      Height          =   885
      Left            =   600
      Top             =   4440
      Visible         =   0   'False
      Width           =   780
   End
   Begin VB.Image imgRapMask 
      Height          =   885
      Left            =   2040
      Top             =   480
      Visible         =   0   'False
      Width           =   780
   End
   Begin VB.Image imgBullet1 
      Height          =   60
      Left            =   4080
      Top             =   4680
      Visible         =   0   'False
      Width           =   60
   End
   Begin VB.Image imgBullet2 
      Height          =   60
      Left            =   4080
      Top             =   5280
      Visible         =   0   'False
      Width           =   60
   End
   Begin VB.Image imgExplode 
      Height          =   465
      Left            =   1560
      Top             =   5520
      Visible         =   0   'False
      Width           =   450
   End
   Begin VB.Image imgExplodeMask 
      Height          =   465
      Left            =   1320
      Top             =   4440
      Visible         =   0   'False
      Width           =   450
   End
   Begin VB.Image imgSmallRap 
      Height          =   375
      Left            =   5160
      Top             =   5880
      Visible         =   0   'False
      Width           =   330
   End
   Begin VB.Image imgSmallRapMask 
      Height          =   375
      Left            =   4800
      Top             =   4800
      Visible         =   0   'False
      Width           =   330
   End
   Begin VB.Image imgBBullet 
      Height          =   120
      Left            =   2040
      Top             =   6240
      Visible         =   0   'False
      Width           =   120
   End
   Begin VB.Image imgBBulletMask 
      Height          =   120
      Left            =   2520
      Top             =   3960
      Visible         =   0   'False
      Width           =   120
   End
End
Attribute VB_Name = "FrmSpaceImpact"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Option Explicit

Const MaxBadGuys = 4            'Max Number of Bad Guys on the Screen (Keep this number small)
Const MaxBullets = 25           'Max Number of Bullets you can fire
Const MaxEnemyBullets = 25      'Max Number of Bullets the enemy can fire
Const MaxAccel = 100            'Max Acceleration of Your Plane
Const EnemyFireInterval = 50    'The interval at which enemys will shoot
Const EnemySpeed = 75           'Speed at which enemies move

Public Backy As Long            'Position of the Background
Public gX As Long               'Global X position of your plane
Public gY As Long               'Global y position of your plane
Public XV As Long               'Velocity in the X direction
Public YV As Long               'Velocity in the Y direction
Public MouseX As Long           'Mouse X position
Public MouseY As Long           'Mouse Y position
Public SpaceIsPressed As Boolean            'Indicates that the space bar is pressed (fire)
Dim BadX(1 To MaxBadGuys) As Long           'Bad Guy X positions
Dim BadY(1 To MaxBadGuys) As Long           'Bad Guy Y positions
Dim BulletX(1 To MaxBullets) As Long        'BulletX positions
Dim BulletY(1 To MaxBullets) As Long        'BulletY positions
Dim BBulletX(1 To MaxEnemyBullets) As Long  'Bad Guy Bullet X positions
Dim BBulletY(1 To MaxEnemyBullets) As Long  'Bad Guy BUllet Y positions
Dim BulletCount As Long         'Number of bullets fired
Dim FireToggle As Boolean       'Toggles the flames comming out of the wings from your guns
Dim BulletToggle As Boolean     'Toggles the bullets direction
Public StartBullet As Integer   'The starting counter for bullets
Public CurrBullet As Integer    'The current bullet last fired
Public BCurrBullet As Integer   'Bad Guy current bullet last fired
Public Score As Long            'Current Score
Public Lives As Integer         'Number of Lives you have left
Public BBuletTimer As Integer   'Counter for enemy firing
Public EFireCount As Integer    'Counter for enemy firing
Public BeginGame As Boolean     'Indicates to begin the game
Public Shields As Long          'Amount of shields left on your ship


Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Dim i As Integer
    Select Case KeyCode
        Case vbKeySpace
            SpaceIsPressed = True
            If BeginGame = False Then
                BeginGame = True
                gX = Me.Width / 2 - Me.imgRap.Width / 2
                gY = Me.Height - Me.imgRap.Height - 300
                For i = 1 To MaxBadGuys         'position of the bad guys
                    BadX(i) = Rnd * Me.Width
                    BadY(i) = (Rnd * Me.Height) - Me.Height
                Next
                StartBullet = 1
                Lives = 3
                For i = 1 To MaxBullets
                    BulletY(i) = -100
                Next
                For i = 1 To MaxEnemyBullets
                    BBulletY(i) = Me.Height
                Next
                SpaceIsPressed = False
                Me.Shields = 4000
                Score = 0
            End If
        Case vbKeyF2
            BeginGame = True
            gX = Me.Width / 2 - Me.imgRap.Width / 2
            gY = Me.Height - Me.imgRap.Height - 300
            For i = 1 To MaxBadGuys         'position of the bad guys
                BadX(i) = Rnd * Me.Width
                BadY(i) = (Rnd * Me.Height) - Me.Height
            Next
            StartBullet = 1
            Lives = 3
            For i = 1 To MaxBullets
                BulletY(i) = -100
            Next
            For i = 1 To MaxEnemyBullets
                BBulletY(i) = Me.Height
            Next
            SpaceIsPressed = False
            Me.Shields = 4000
            Me.Timer1.interval = 1
            Score = 0
        Case vbKeyP
            If Me.Timer1.interval = 0 Then
                Me.Timer1.interval = 1
            Else
                Me.Timer1.interval = 0
                Me.FontSize = 28
                Me.CurrentX = Me.Width / 2 - Me.TextWidth("Paused") / 2
                Me.CurrentY = Me.Height / 2 - 2000
                Me.Print "Paused"
            End If
            
    End Select
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
FrmCheat.Visible = True
End If
End Sub
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
        Case vbKeySpace
            SpaceIsPressed = False
    End Select
End Sub

Private Sub Form_Load()
On Error Resume Next
    Dim i As Integer
Call loadimg
    StartBullet = 1                 'start counter for bullets
    Lives = 3                       'starting number of lives
    gX = Me.imgRapFire.Left         'position of your plane
    gY = Me.imgRapFire.Top
    For i = 1 To MaxBadGuys         'position of the bad guys
        BadX(i) = Rnd * Me.Width
        BadY(i) = Rnd * Me.Height
    Next
    Me.DrawStyle = 0
    Me.FillStyle = 0
    Me.FillColor = vbGreen
    Me.Shields = 4000
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    SpaceIsPressed = True
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    MouseX = X
    MouseY = Y
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    SpaceIsPressed = False
End Sub

Private Sub Form_Unload(Cancel As Integer)
Unload Me
End Sub

Private Sub Timer1_Timer()
On Error GoTo hell
    Dim i As Integer    'counter
    Dim j As Integer    'counter
    Dim TempX As Long
    Dim TempY As Long
    Me.Cls
        If MouseX > gX Then XV = XV + 10
    If MouseX < gX Then XV = XV - 10
    If MouseY > gY Then YV = YV + 10
    If MouseY < gY Then YV = YV - 10

    If XV > MaxAccel Then XV = MaxAccel
    If -XV > MaxAccel Then XV = -MaxAccel
    If YV > MaxAccel Then YV = MaxAccel
    If -YV > MaxAccel Then YV = -MaxAccel
    
    gX = gX + XV
    gY = gY + YV
    
    If gX < 0 Then gX = 0: XV = 0
    If gY < 0 Then gY = 0: YV = 0
    If gX > Me.Width - Me.imgRap.Width Then gX = Me.Width - Me.imgRap.Width: XV = 0
    If gY > Me.Height - Me.imgRap.Height Then gY = Me.Height - Me.imgRap.Height: YV = 0
    
    Backy = Backy + 25
    If Backy > Me.imgBackGround.Height Then Backy = 0
    For i = 1 To Me.Width Step Me.imgBackGround.Width
        For j = -(Me.imgBackGround.Height) To Me.Height Step Me.imgBackGround.Height
            Me.PaintPicture Me.imgBackGround.Picture, i, j + Backy
        Next
    Next
    
    If SpaceIsPressed And FireToggle = True Then
        CurrBullet = CurrBullet + 1
        If CurrBullet > MaxBullets Then CurrBullet = 1: StartBullet = 1
        BulletX(CurrBullet) = gX
        BulletY(CurrBullet) = gY
        Me.PaintPicture Me.imgRapFireMask.Picture, gX, gY, , , , , , , vbSrcAnd
        Me.PaintPicture Me.imgRapFire.Picture, gX, gY, , , , , , , vbSrcPaint
        FireToggle = False
    Else
        Me.PaintPicture Me.imgRapMask.Picture, gX, gY, , , , , , , vbSrcAnd
        Me.PaintPicture Me.imgRap.Picture, gX, gY, , , , , , , vbSrcPaint
        FireToggle = True
    End If
    For i = StartBullet To MaxBullets
        BulletY(i) = BulletY(i) - 125
        If BulletY(i) > 0 Then
            If BulletToggle = True Then
          
                Me.PaintPicture Me.imgBullet1.Picture, BulletX(i) + Me.imgBullet1.Width, BulletY(i), , , , , , , vbSrcAnd
                Me.PaintPicture Me.imgBullet2.Picture, BulletX(i) + Me.imgBullet1.Width, BulletY(i), , , , , , , vbSrcPaint
                Me.PaintPicture Me.imgBullet1.Picture, BulletX(i) + Me.imgRap.Width - Me.imgBullet1.Width, BulletY(i), , , , , , , vbSrcAnd
                Me.PaintPicture Me.imgBullet2.Picture, BulletX(i) + Me.imgRap.Width - Me.imgBullet1.Width, BulletY(i), , , , , , , vbSrcPaint
                BulletToggle = False
            Else
                Me.PaintPicture Me.imgBullet2.Picture, BulletX(i) + Me.imgBullet1.Width, BulletY(i), , , , , , , vbSrcAnd
                Me.PaintPicture Me.imgBullet1.Picture, BulletX(i) + Me.imgBullet1.Width, BulletY(i), , , , , , , vbSrcPaint
                Me.PaintPicture Me.imgBullet2.Picture, BulletX(i) + Me.imgRap.Width - Me.imgBullet1.Width, BulletY(i), , , , , , , vbSrcAnd
                Me.PaintPicture Me.imgBullet1.Picture, BulletX(i) + Me.imgRap.Width - Me.imgBullet1.Width, BulletY(i), , , , , , , vbSrcPaint
    
                BulletToggle = True
            End If
            For j = 1 To MaxBadGuys
                If BulletY(i) > BadY(j) And BulletY(i) < (BadY(j) + Me.imgBadGuy.Height) And BulletY(i) > 1 Then
                    If BulletX(i) > BadX(j) - Me.imgRap.Width And BulletX(i) < (BadX(j) + Me.imgBadGuy.Width) Then
                        Me.PaintPicture Me.imgExplodeMask.Picture, BadX(j), BadY(j), , , , , , , vbSrcAnd
                        Me.PaintPicture Me.imgExplode.Picture, BadX(j), BadY(j), , , , , , , vbSrcPaint
                        BadY(j) = -(Me.imgBadGuy.Height)
                        BadX(j) = Rnd * Me.Width
                        BulletY(i) = -100
                        If BeginGame = True Then Score = Score + 10
                    End If
                End If
            Next
        End If
    Next

    
    For i = 1 To MaxBadGuys
        EFireCount = EFireCount + 1
        BadY(i) = BadY(i) + EnemySpeed
        If BadX(i) > gX Then BadX(i) = BadX(i) - 25
        If BadX(i) < gX Then BadX(i) = BadX(i) + 25
        If BadY(i) > Me.Height Then BadY(i) = -Me.imgBadGuy.Height: BadX(i) = Rnd * Me.Width
        If BadY(i) < Me.Height Then
            Me.PaintPicture Me.imgBadGuyMask, BadX(i), BadY(i), , , , , , , vbSrcAnd
            Me.PaintPicture Me.imgBadGuy, BadX(i), BadY(i), , , , , , , vbSrcPaint
        End If
        If EFireCount > (EnemyFireInterval + Rnd * 100) Then
            BCurrBullet = BCurrBullet + 1: EFireCount = 1
            If BCurrBullet > MaxEnemyBullets Then BCurrBullet = 1
            BBulletX(BCurrBullet) = BadX(i) + Me.imgBadGuy.Width / 2 - Me.imgBBullet.Width / 2
            BBulletY(BCurrBullet) = BadY(i)
        End If
        If BeginGame = True Then
            If BadY(i) + Me.imgBadGuy.Height > gY And BadY(i) < gY + Me.imgRap.Height Then
                If BadX(i) + Me.imgBadGuy.Width > gX And BadX(i) < gX + Me.imgRap.Width Then
                    Shields = Shields - 400
                    For j = 1 To 100
                        TempX = BadX(i) + Rnd * Me.imgBadGuy.Width
                        TempY = BadY(i) + Rnd * Me.imgBadGuy.Height
                        Me.PaintPicture Me.imgExplodeMask, TempX, TempY, , , , , , , vbSrcAnd
                        Me.PaintPicture Me.imgExplode, TempX, TempY, , , , , , , vbSrcPaint
                    Next
                    If Shields <= 0 Then
                        Lives = Lives - 1
                        For j = 1 To 250
                            TempX = gX + Rnd * Me.imgRap.Width
                            TempY = gY + Rnd * Me.imgRap.Height
                            Me.PaintPicture Me.imgExplodeMask, TempX, TempY, , , , , , , vbSrcAnd
                            Me.PaintPicture Me.imgExplode, TempX, TempY, , , , , , , vbSrcPaint
                        Next
                        If Lives = -1 Then
                            Me.Timer1.interval = 0
                            Me.FontSize = 32
                            Me.CurrentX = Me.Width / 2 - Me.TextWidth("GAME OVER") / 2
                            Me.CurrentY = Me.Height / 2 - 2000
                            Me.Print "GAME OVER"
                            Me.FontSize = 28
                            Me.Print ""
                            Me.CurrentX = Me.Width / 2 - Me.TextWidth("Press F2 To Start Over") / 2
                            Me.Print "Press F2 To Start Over"
                        End If
                        
                        Shields = 4000
                    End If
                    BadY(i) = Me.Height
                End If
            End If
        End If
    Next
        For i = 1 To MaxEnemyBullets
        BBulletY(i) = BBulletY(i) + EnemySpeed + 25
        If BBulletX(i) > gX Then BBulletX(i) = BBulletX(i) - 25
        If BBulletX(i) < gX Then BBulletX(i) = BBulletX(i) + 25
        If BBulletY(i) < Me.Height Then
            If BeginGame = True Then
                If BBulletY(i) < gY + Me.imgRap.Height And BBulletY(i) > gY Then
                    If BBulletX(i) < gX + Me.imgRap.Width And BBulletX(i) > gX Then
                        Shields = Shields - 100
                        If Shields <= 0 Then
                            Lives = Lives - 1
                            For j = 1 To 250
                                TempX = gX + Rnd * Me.imgRap.Width
                                TempY = gY + Rnd * Me.imgRap.Height
                                Me.PaintPicture Me.imgExplodeMask, TempX, TempY, , , , , , , vbSrcAnd
                                Me.PaintPicture Me.imgExplode, TempX, TempY, , , , , , , vbSrcPaint
                            Next
                            If Lives = -1 Then
                                Me.Timer1.interval = 0
                                Me.FontSize = 32
                                Me.CurrentX = Me.Width / 2 - Me.TextWidth("GAME OVER") / 2
                                Me.CurrentY = Me.Height / 2 - 2000
                                Me.Print "GAME OVER"
                                Me.FontSize = 28
                                Me.Print ""
                                Me.CurrentX = Me.Width / 2 - Me.TextWidth("Press F2 To Start Over") / 2
                                Me.Print "Press F2 To Start Over"
                            End If
                            
                            Shields = 4000
                        End If
                        Me.PaintPicture Me.imgExplodeMask, BBulletX(i), BBulletY(i), , , , , , , vbSrcAnd
                        Me.PaintPicture Me.imgExplode, BBulletX(i), BBulletY(i), , , , , , , vbSrcPaint
                        BBulletY(i) = Me.Height
                    End If
                End If
            End If
            Me.PaintPicture Me.imgBBulletMask, BBulletX(i), BBulletY(i), , , , , , , vbSrcAnd
            Me.PaintPicture Me.imgBBullet, BBulletX(i), BBulletY(i), , , , , , , vbSrcPaint
        End If
    Next
    
    For i = 1 To Lives
        Me.PaintPicture Me.imgSmallRapMask.Picture, 100 + (i * (Me.imgSmallRap.Width + 25)), 400, , , , , , , vbSrcAnd
        Me.PaintPicture Me.imgSmallRap.Picture, 100 + (i * (Me.imgSmallRap.Width + 25)), 400, , , , , , , vbSrcPaint
    Next
        If BeginGame = False Then
        Me.FontSize = 16
        Me.CurrentX = Me.Width / 2 - Me.TextWidth("BLacK PeaRL Space Impact") / 2
        Me.CurrentY = Me.Height / 2 - 2000
        Me.Print "BLacK PeaRL Space Impact"
        Me.CurrentX = Me.Width / 2 - Me.TextWidth("Tekan Spasi Untuk Memulai Game") / 2
        Me.Print "Tekan Spasi Untuk Memulai Game"
        Me.CurrentX = Me.Width / 2 - Me.TextWidth("Gunakan Mouse kamu untuk mengontrol Kapal") / 2
        Me.Print "Gunakan Mouse kamu untuk mengontrol Kapal"
        Me.CurrentX = Me.Width / 2 - Me.TextWidth("Klik Kanan/Kiri Untuk Menembak Musuh") / 2
        Me.Print "Klik Kanan/Kiri Untuk Menembak Musuh"
    End If
    
    Me.Line (100, (Me.Height - 1000) - Shields)-(300, Me.Height - 1000), vbRed, B
    
    Me.FontSize = 12
    Me.CurrentX = 100
    Me.CurrentY = 100
    Me.Print "Score: " & Score
    Me.CurrentX = Me.Width - 2500
    Me.CurrentY = Me.Height - 800
    Me.Print "BLacK PeaRL Game "
    
    'if the user has paused then show the word in the center of the screen
    If Me.Timer1.interval = 0 And Lives >= 0 Then
        Me.FontSize = 28
        Me.CurrentX = Me.Width / 2 - Me.TextWidth("Paused") / 2
        Me.CurrentY = Me.Height / 2 - 2000
        Me.Print "Paused"
    End If
hell:
    If Err.Number = 481 Then
    MsgBox "Path gambar tidak ditemukan", vbCritical, "Error"
    Unload Me
    End If
    
End Sub

Private Sub loadimg()
Set imgBackGround.Picture = LoadPicture(App.Path & "/Resource/SpaceImpact/imgBackGround.jpg")
Set imgRapMask.Picture = LoadPicture(App.Path & "/Resource/SpaceImpact/imgRapMask.jpg")
Set imgRapFire.Picture = LoadPicture(App.Path & "/Resource/SpaceImpact/imgRapFire.jpg")
Set imgRapFireMask.Picture = LoadPicture(App.Path & "/Resource/SpaceImpact/imgRapFireMask.jpg")
Set imgRap.Picture = LoadPicture(App.Path & "/Resource/SpaceImpact/imgRap.jpg")
Set imgBadGuyMask.Picture = LoadPicture(App.Path & "/Resource/SpaceImpact/imgBadGuyMask.jpg")
Set imgBadGuy.Picture = LoadPicture(App.Path & "/Resource/SpaceImpact/imgBadGuy.jpg")
Set imgExplode.Picture = LoadPicture(App.Path & "/Resource/SpaceImpact/imgExplode.jpg")
Set imgExplodeMask.Picture = LoadPicture(App.Path & "/Resource/SpaceImpact/imgExplodeMask.jpg")
Set imgBBullet.Picture = LoadPicture(App.Path & "/Resource/SpaceImpact/imgBBullet.jpg")
Set imgBBulletMask.Picture = LoadPicture(App.Path & "/Resource/SpaceImpact/imgBBulletMask.jpg")
Set imgBullet2.Picture = LoadPicture(App.Path & "/Resource/SpaceImpact/imgBullet2.jpg")
Set imgBullet1.Picture = LoadPicture(App.Path & "/Resource/SpaceImpact/imgBullet1.jpg")
Set imgSmallRapMask.Picture = LoadPicture(App.Path & "/Resource/SpaceImpact/imgSmallRapMask.jpg")
Set imgSmallRap.Picture = LoadPicture(App.Path & "/Resource/SpaceImpact/imgSmallRap.jpg")

End Sub

